﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="treewz.aspx.cs" Inherits="weba.treewz" %>

<%@ Register Assembly="C1.Web.Wijmo.Controls.4, Version=4.0.20133.145, Culture=neutral, PublicKeyToken=9b75583953471eea" Namespace="C1.Web.Wijmo.Controls.C1AutoComplete" TagPrefix="wijmo" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <style type="text/css">
        .ysa {
            float: left;
            width: 600px;
            vertical-align: middle;
        }
        #container {
            height: 400px;
            width: 640px;
            float: right;
        }
        .pangdt {
            overflow: visible;
        }
        .ysab {
            width: 280px;
            float: left;
            height: 900px;
            overflow: auto;
        }
    </style>
    
  <%--  <script type="text/javascript" src="Scripts/ditujs.js"></script>--%>
</head>
<body onLoad="initialize()">
    <form id="form1" runat="server">
        <div>
       
        <asp:Panel ID="Panel1" runat="server" ScrollBars="Vertical" Width="950px" CssClass="pangdt" Height="980px">
             <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
            <Services>
                <asp:ServiceReference Path="wajax.asmx"  />
            </Services>
        </asp:ScriptManager>
       <div class="ysab">
        <asp:TreeView ID="TreeView1" runat="server" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged" ></asp:TreeView>
        
        </div>
      <%--  <iframe name="ybf" width="640px" height="500px" style="float: right" id="fm" src="dituxianshi.aspx"></iframe>--%>
            <div id="container"></div> 
            <div class="ysa">
            后退：<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/fanhui.jpg" Height="80px" Width="80px" OnClick="ImageButton1_Click" />
              刷新： <img alt="" src="Images/shuaxing.jpg"width="80px" height="80px" onclick="javascript: window.location.reload();" />
         清空：  <img alt="" src="Images/qingchu.jpg" width="80px" height="80px"  onclick="javascript:      window.location.href='treewz.aspx';" /> 定位： <img alt="" src="Images/dingwei.jpg" width="80px" height="80px"   onclick="javascript:toolBar.doLocation()" /> 
                <br/> <br/> 
                 搜索所有网点数据：<wijmo:C1AutoComplete ID="C1AutoComplete1" runat="server" DataLabelField="name" DataMember="DefaultView" DataSourceID="LinqDataSource1" DataValueField="Id" Text="输入后根据id搜索" Width="250px"></wijmo:C1AutoComplete>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="weba.sjklqDataContext" EntityTypeName="" TableName="dituwz">
        </asp:LinqDataSource>
                <asp:Button ID="Button1" runat="server" Text="搜索" OnClick="Button1_Click" />

            </div>
             </asp:Panel>
       </div>
        </form>
</body>
</html>
<%--<script type="text/javascript"
	src="http://webapi.amap.com/maps?v=1.2&key=ab5ae8097e26040fa604012b73e78f03">
</script> 
   
<script type="text/javascript"></script> --%>
    
       <script type="text/javascript"
	src="http://webapi.amap.com/maps?v=1.2&key=ab5ae8097e26040fa604012b73e78f03">
</script> 
   <%--    <script type="text/javascript" src="Scripts/jquery-1.8.2.min.js"></script> --%>  
<script type="text/javascript">
    var ln;
    var point;
    var mapObj;
    var zom;
    var toolBar, locationInfo;
    var myBoolean = false;
    var tool;
    function raa() {

        // x=   WebService.HelloWorld();
        //  alert("adda");
        //  x = ln.getLng();
        //  var y = ln.getlnt();
        alert(x);

    }
    function x() {
        //  $("#fm").attr("src", "dituxianshi.aspx");

        toolBar.doLocation()
        //  myBoolean = true;
    }
    function a() {
        //  weba.wajax.HelloWorld(onresult);
        x = ln.getLng();
        y = ln.getLat();
        weba.wajax.xiougai(x, y, '<%= Request.QueryString["id"] %>', onresult)

    }
    function onresult(result) {
        alert(result);
    }
    function xh(rx, ry, d, nm, sm, ig) {
        var marker = new AMap.Marker({
            id: d,
            draggable: true,
            position: new AMap.LngLat(rx, ry),
            icon: "http://webapi.amap.com/static/images/marker_sprite.png",
            offset: { x: -8, y: -34 }
        });// 创建点坐标
        mapObj.addOverlays(marker);

        var info = [];
        info.push("<img src='Images/" + ig + "'width='30' height='30'>");
        info.push("&nbsp;编号:"+d + sm + "<br  />");
        info.push("&nbsp;&nbsp;" + nm);

        var inforWindow = new AMap.InfoWindow({
            //offset: new AMap.Pixel(45, -34),
            offset: new AMap.Pixel(0, -23),
            content: info.join("")
        });
        AMap.event.addListener(marker, "click", function (e) {
            inforWindow.open(mapObj, marker.getPosition());
        });
        AMap.event.addListener(marker, "dragend", function (e) {
            var nx = e.lnglat.getLng();
            var ny = e.lnglat.getLat();
            if (confirm("确定要更新" + nm + "吗？")) {// alert();
                weba.wajax.genxing(nx, ny, d, onresult)
            }
        });
    }
    function onresult(result) {
        alert(result);
    }
    function suc(result) {
        var ps = new AMap.LngLat(result[0].lx, result[0].ly);
        // alert(result.length);
        mapObj.setCenter(ps);
        mapObj.setZoom(zom);

        for (var i = 0; i < result.length; i++) {
            xh(result[i].lx, result[i].ly, result[i].Id, result[i].name, result[i].shuoming, result[i].tupianurl);
            //var marker = new AMap.Marker({
            //    id: result.Id,
            //    position: new AMap.LngLat(result[i].lx, result[i].ly),
            //    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
            //    offset: { x: -8, y: -34 }
            //});// 创建点坐标
            //mapObj.addOverlays(marker);

            //var info = [];
            //info.push("<b>&nbsp;&nbsp;" + result[i].name + "</b>");
            //info.push("&nbsp;&nbsp;" + result[i].shuoming);
            //info.push("&nbsp;&nbsp;" + result[i].Id);

            //var inforWindow = new AMap.InfoWindow({
            //    offset: new AMap.Pixel(45, -34),
            //    content: info.join("<br  />")
            //});
            //AMap.event.addListener(marker, "click", function (e) {
            //    inforWindow.open(mapObj, marker.getPosition());
            //});
        }

        //if (myBoolean == true)
        //{
        //    //  toolBar.doLocation()
        //    alert("a");
        //}
    }
    function initialize() {
        pd = '<%= Request.QueryString["pid"] %>'
        zom = '<%= Request.QueryString["zm"] %>'
        mapObj = new AMap.Map("container"); // 创建地图实例
        if (pd == "") {
            point = new AMap.LngLat(121.550331, 29.868038); // 创建点坐标
            mapObj.setCenter(point);
        }
        else {
            weba.wajax.getbyid(pd, suc);
            point = new AMap.LngLat(121.550331, 29.868038);
            //point = new AMap.LngLat(jd, wd);
            //var markera = new AMap.Marker({
            //    id: "m122",
            //    position: new AMap.LngLat(jd, wd),
            //    icon: "http://webapi.amap.com/static/images/marker_sprite.png",
            //    offset: { x: -8, y: -34 }
            //});// 创建点坐标
            //mapObj.addOverlays(markera);
        }

        //  alert(ln.getLng());
        mapObj.plugin(["AMap.ToolBar", "AMap.OverView,AMap.Scale"], function () {
            // 加载工具条
            tool = new AMap.ToolBar({
                direction: false, // 隐藏方向导航
                ruler: false, // 隐藏视野级别控制尺
                autoPosition: false // 禁止自动定位
            });
            mapObj.addControl(tool);

            // 加载鹰眼
            view = new AMap.OverView();
            mapObj.addControl(view);

            // 加载比例尺
            scale = new AMap.Scale();
            mapObj.addControl(scale);
        });
        // var point = new AMap.LngLat(116.404, 39.915); // 创建点坐标
        // 设置地图中心点坐标
        mapObj.plugin(["AMap.ToolBar"], function () {
            toolBar = new AMap.ToolBar(); //设置地位标记为自定义标记  
            mapObj.addControl(toolBar);
            AMap.event.addListener(toolBar, 'location', function callback(e) {
                locationInfo = e.lnglat;
            });
        });

        mapObj.bind(mapObj, "click", function (e) {
            ln = e.lnglat;
            var markera = new AMap.Marker({
                id: "m123",
                position: e.lnglat,
                icon: "http://webapi.amap.com/static/images/marker_sprite.png",
                offset: { x: -8, y: -34 }
            });
            //  alert(ln.getLng());
            mapObj.addOverlays(markera);
            mapObj.setCenter(ln);

        });
    }

</script>
   